let test = 666;
; (function (window, undefined) {
  function init(el) {
    //获取所有的数据
    let els = document.querySelectorAll(el)
    //for循环遍历
    for (let i = 0; i < els.length; i++) {
      //i是索引  获取js标签对象
      this[i] = els[i]
    }
    this.length = els.length
  }
  let jQuery = function (el) {
    return new init(el)
  }
  jQuery.extend = function (object) {
    //  object={方法名(){},....}
    for (let key in object) {
      init.prototype[key] = object[key]
    }
  }

  init.prototype = {
    css(cssAttr, cssVal) {
      console.log(1, this)  //构造函数中的this
      // this[0].style.cssAttr=cssVal
      // this[1].style.cssAttr=cssVal
      // this[2].style.cssAttr=cssVal
      for (let i = 0; i < this.length; i++) {
        this[i].style.cssAttr = cssVal  //当对象的键是变量时，用数组语法
        this[i].style[cssAttr] = cssVal
      }
    },
    ajax(options) { },
    attr(options) { },
    addclass(options) { },
  }

  window.jQuery = window.$ = jQuery
})(window)

// let jqobj=$('div')
// console.log(jqobj)
// jqobj.css('color','red')
$.extend({
  bg() { }
})

console.log($('div'));